package com.mls.fivedistrict.controller.portal;

import com.github.pagehelper.PageInfo;
import com.mls.fivedistrict.common.PageFilter;
import com.mls.fivedistrict.common.ServiceResponse;
import com.mls.fivedistrict.controller.BaseController;
import com.mls.fivedistrict.pojo.ReceiveRecord;
import com.mls.fivedistrict.server.ReceiveRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 所有已接受的记录
 * Created by chenxiuxiang on 2018/4/13.
 */
@RestController
@RequestMapping("/api/app")
public class ReceiveRecordController extends BaseController {
    @Autowired
    ReceiveRecordService receiveRecordService;


    @GetMapping(path = "/v1/records")
    public ServiceResponse getRecords() {
        PageFilter pageFilter = getPageFilter();
        Map<String, String> filterMap = pageFilter.getFilterMap();
        filterMap.put("userId", getUser().getId() + "");
        PageInfo pageInfo = receiveRecordService.getAllRecord(pageFilter);
        return ServiceResponse.createSuccessResponse(pageInfo);
    }

}
